package com.kaifamiao.wendao.utils;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import java.util.logging.Logger;

public class MyBatisHelper {

    private static Logger logger = Logger.getAnonymousLogger();
    private static SqlSessionFactory sessionFactory ;

    public static void init( SqlSessionFactory factory ){
        logger.info( "初始化会话工厂" );
        sessionFactory = factory ;
    }

    // 使用会话工厂开启会话并将新会话返回
    public static SqlSession open(){
        logger.info( "开启会话" );
        SqlSession session = sessionFactory.openSession();
        return session;
    }

}
